package cn.leelei.springmvc.controller.format;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import org.springframework.format.Formatter;
/**
 * 
 * Date 转化 String 
 * String 转化 Date
 * @author Administrator
 *
 */
public class DateFormat implements Formatter<Date> {
	private static final  SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd");
	
	/**
	 * 响应
	 */
	@Override
	public String print(Date object, Locale locale) {
		return FORMAT.format(object);
	}
	/**
	 * 请求
	 */
	@Override
	public Date parse(String text, Locale locale) throws ParseException {
		return FORMAT.parse(text);
	}

}
